<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

/**
1 路由变量支持：   a 冒号:名  :xxx    b <xxx>
2 路由分割符：/ - _
 **/
Route::get('think-:name', function ($name) {
    return 'hello,ThinkPHP6!'.$name;
});

Route::get('hello/:name', 'index/hello');


///Route::rule("/cd","City/details");
//Route::rule("/cd/:id","City/details");
//Route::rule("/cd/:name","City/details");

//Route::rule("/cd/:id","City/details","GET");
//Route::rule("/cd/:id","City/details","POST|GET");
//Route::rule("/","City/details","POST|GET");

//Route::rule("/cd/:id","City/details")->pattern(["id"=>"\d+"]);

//Route::rule("/cs/:id/:uid","City/show")->pattern([
//    "id"=>"\d+",
//    "uid"=>"[a-z]+"
//]);

//Route::pattern([
//    "id"=>"\d+",
//    "uid"=>"[a-z]+"
//    ]
//);
//Route::rule("/cs/:id/:uid","City/show");

//Route::rule("/cs-:id-:uid","City/show");
//Route::rule("/cs-<id>-<uid>","City/show");
//http://127.0.0.1:8090/hi-world-55
//Route::rule("/hi-<name>-<id>","Hello:name/index");
//http://127.0.0.1:8090/hi/world/55
//Route::rule("/hi/:name/:id","Hello:name/index");
//http://127.0.0.1:8090/hi-world-55
//Route::rule("/hi-:name-:id","Hello:name/index");

//Route::rule("/bd/:id","Group.Blog/details");

//Route::rule("/cd/:id","City/details2");
//Route::rule("/cd/:id","app\controller\City@details2");
//Route::rule("/cd/:id","app\controller\City::details2");
//Route::redirect("/cd/:id","http://www.baidu.com");
//Route::rule("/cd/:id","City/details")->ext("xhtml");
//Route::rule("/cd/:id","City/details")->ext("xhtml|asp")->https();
//Route::rule("/cd/:id","City/details")->denyExt("html|xhtml");
//Route::rule("/cd/:id","City/details")->domain("localhost");
//Route::rule("/cd/:id","City/details")->filter(['id'=>9]); 没有用
//Route::rule("/cd/:id","City/details")->append(['type'=>9]);
//Route::rule("/cd/:id","City/details")->option([
//    "ext"=>"html",
//    "denExt"=>["jpg"],
//    "append"=>["type"=>"美国"]
//]);

//Route::domain("localhost",function(){
//    Route::rule("/cd/:id","City/details2");
//});

//Route::rule("/cd/:id","City/details")->allowCrossDomain();
//Route::group("/city",function(){
//    Route::rule("/cs-:id-:uid","City/show");
//    Route::rule("/cd/:id","City/details");
//
//});

//Route::group("/city",function(){
//    Route::rule(":id/:uid","City/show");
//    Route::rule(":id","City/details");
//
//})->ext("html")->pattern(["id"=>"\d+","uid"=>"[a-z]+"]);

//http://localhost:8090/city/55/abc.html
//Route::group("/city",function(){
//    Route::rule(":id/:uid","show");
//    //Route::rule(":id","details");
//    Route::miss("miss");
//})->ext("html")->prefix("City/")->pattern(["id"=>"\d+","uid"=>"[a-z]+"]);

//访问不存在的页面时
//Route::miss("/public/miss");

//Route::rule("/u$","Url/index");
//Route::rule("/u/:id$","Url/detail")->name("u");

//Route::get("/replay/:id$","Replay/get")->cache(3600);

//Route::get("/v/:id","Verify/route")->validate(\app\validate\User::class,'route');
Route::get("/v/:id","Verify/route")->validate([
    'id'=>\think\validate\ValidateRule::isNumber(null,"必须是数值啊，老表")
],null);


//Route::get("/sa/:id","Store/auth")->middleware(\app\middleware\Auth::class);
//Route::get("/sa/:id","Store/auth")
//    ->middleware([\app\middleware\Auth::class,\app\middleware\Check::class],"nice");

Route::get("/sa/:id","Store/auth")
    ->middleware(function(\think\Request $request,Closure $next,$param){


        echo "cao".$param;
        return $next($request);
    },"nice");